package com.QK.cnstudy.entity;

import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class Sentence {
    private int id;
    private int workId;
    private String content;
    private String translation;

    public Sentence() {

    }

    public void saveToDB(SQLiteDatabase sqLiteDatabase) {
        sqLiteDatabase.execSQL("insert into sentence values(?,?,?,?)", new Object[] { getId(), getWorkId(),
                        getContent(), getTranslation() });
    }

    public Sentence(String[] strings) {

        int len = strings.length;
        id = Integer.valueOf(strings[0]);
        content = len > 1 ? strings[1] : "";
        translation = len > 2 ? strings[2] : "";
    }

    public void setInfoFromCursor(Cursor cursor) {
        int tmp;
        if ((tmp = cursor.getColumnIndex("id")) != -1) {
            setId(cursor.getInt(tmp));
        }
        if ((tmp = cursor.getColumnIndex("work_id")) != -1) {
            setWorkId(cursor.getInt(tmp));
        }
        if ((tmp = cursor.getColumnIndex("content")) != -1) {
            setContent(cursor.getString(tmp));
        }
        if ((tmp = cursor.getColumnIndex("translation")) != -1) {
            setTranslation(cursor.getString(tmp));
        }
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getWorkId() {
        return workId;
    }

    public void setWorkId(int workId) {
        this.workId = workId;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getTranslation() {
        return translation;
    }

    public void setTranslation(String translation) {
        this.translation = translation;
    }

    public String getWordlist() {
        return "";
    }

    public void setWordlist(String wordlist) {

    }

}
